<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="product in products">
                <input type="number" v-model.number="product.quantity"/>
                  {{product.name}}
                <span v-if="product.quantity === 0">
                    - OUT OF STOCK
                </span>
                <button @click="product.quantity +=1">
                    ADD
                </button>
            </li>
            <h2>Total Inventory: {{ totalProducts }}</h2>
        </ul>
    </div>
    <script src="vue.min.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                products: []
            },
            computed: {
                totalProducts () {
                    return this.products.reduce((sum, product) => {
                        return sum + product.quantity
                    }, 0)
                }
            },
            created() {
                this.products = [
                    {
                        "id":1, "quantity":1, "name":"Compass"
                    },
                    {
                        "id":2, "quantity":0, "name":"Jacket"
                    },
                    {
                        "id":3, "quantity":5, "name":"Hiking Socks"
                    },
                    {
                        "id":4, "quantity":2, "name":"Suntan Lotion"
                    }
                ]
            }
        })
    </script>
</body>

</html>